<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>相似产品</title>
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/page.css">
    <script src="../js/jquery-3.2.1.min.js"></script>
    <script src="../js/media.js"></script>
    <script src="../js/common.js"></script>



    <style>
        .bd-0 {
            display: none;
        }

        .active {
            display: block;
        }
        .p1{
        	height: 0.12rem;
        	line-height: 0.12rem;
        	overflow: hidden;
        }
    </style>
</head>

<body>
    <!--头部-->
    <div class="public-header flex">
        <!--<span class="public-header-left-search"></span>-->
        <span class="public-header-left-back"></span>
        <span class="public-header-center">相似产品</span>
        <span class="public-header-right"></span>
    </div>

    <!--正文-->
    <div class="Similar-to-the-auction bc-gray">
        <ul class="clearfix">
            <li v-for='item in data' >
                <div v-if="item.whitchType == 1" @click="nextUrl(item.produceId)">
                    <img :src="item.produceHeadImage.split(',')[0]" >
                    <p class="p1">{{item.produceDescribe}}</p>
                    <p class="p2 flex">
                        <span>￥:<font>{{item.producePrice}}</font></span>
                        <em @click='add_good(this)'>{{item.produceGoodNum}}</em>
                    </p>
                </div>
                <div v-else @click="nextUrl2(item.produceId)">
                    <img :src="item.produceHeadImage.split(',')[0]" >
                    <p class="p1">{{item.produceDescribe}}</p>
                    <p class="p2 flex">
                        <span>￥:<font>{{item.producePrice}}</font></span>
                        <em @click='add_good(this)'>{{item.produceGoodNum}}</em>
                    </p>
                </div>

            </li>
        
        </ul>




    </div>

    <script src='../js/vue.js'></script>
    <script src='../js/vue-resource.min.js'></script>

    <script>
        $(function () {
            $('.hd a').click(function () {
                var index = $(this).index();
                $(this).addClass('active').siblings().removeClass('active');
                $('.bd-0').eq(index).addClass('active').siblings().removeClass('active');
            })



        })
    </script>
    <script>
        $(function () {
            var value = sessionStorage.produceTitle ;
            new Vue({
                el: 'body',
                data: {
                    thisurl: base_url+'ZITAOHUI/foot/like',
                    data: []
                },
                ready: function () {
                    this.$http.get(this.thisurl, {
                            params: {
                                value:value,
                            }
                        })
                        .then((response) => {
                            //console.log(response);
                            var all_data= response.data.extend;
                            this.$set('data',all_data.list);
                            //console.log(this.data)
                        }, (response) => {
                            //console.log('数据出错')
                        }).catch(function (response) {
                            //console.log(response)
                        });
               

                },
                methods: {
                    add_good: function (t) {
                        console.log(t)

                        this.$http.get(base_url + 'ZITAOHUI/goodNum', {
                            params: {
                                produceId: t.item.produceId,
                                user_id: u_id
                            }
                        }).then(
                            function (data) {
                                // console.log(data)
                                var sun = data.data.extend;
                                sun = sun.haha.list;
                                if (sun == 1) {
                                    t.item.produceGoodNum += 1;
                                } else if (sun == 2) {
                                    alert('网络不好，请稍后再试')
                                } else {
                                    alert('您已经对该商品点过赞啦')
                                }
                            }
                        )
                    },
                    nextUrl(id){
                        window.location.href = "buy-info-page.3.html?p_id="+id+"&time="+new Date().getTime();
                    }
                }
            })
        })
    </script>
</body>

</html>